package cn.tedu.luban.gateway.config;

import cn.tedu.luban.passport.protocol.common.encoder.JwtEncoder;
import cn.tedu.luban.passport.protocol.jwt.UserPrinciple;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PassportConfiguration {
    @Value("${jwt.secret}")
    private String secret;
    @Bean
    @ConditionalOnProperty(prefix="jwt",value="secret")
    public JwtEncoder<UserPrinciple> jwtEncoder(){
        JwtEncoder<UserPrinciple> jwtEncoder=new JwtEncoder<UserPrinciple>();
        jwtEncoder.setSecret(secret);
        return jwtEncoder;
    }
}
